import pkg from '@system.package'
// const needCheckAppList = [
//   'com.jingdong.app.mall',
//   'com.taobao.taobao',
//   'com.achievo.vipsh'
// ]

export default function(needCheckAppList) {
  const checkPermissionList = needCheckAppList.map((app, index) => {
    return new Promise(resolve => {
      pkg
        .hasInstalled({
          package: app
        })
        .then(response => {
          // resolve({ name: app, result: Math.pow(2, index) })
          resolve({ name: app, result: response.data.result ? 1 : 0 })
        })
        .catch(e => {
          resolve({ name: app, result: undefined })
        })
    })
  })
  return Promise.all(checkPermissionList)
}
